<?php

use App\Http\Controllers\TestController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Services\ImageService;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/getimage/{name?}/{thumb?}/{quality?}/{bgcolor?}', function (Request $request) {
    // dump($request->route());
    return ImageService::getimage($request);
})->where([
    'name' => '/?storage/uploads/[\d]{4}-\d{2}-\d{2}/\w+.[a-zA-Z]{3,4}',
    'thumb' => '\d+x\d+',
    'quality' => '\d+',
    'bgcolor' => '[a-zA-Z0-9]{3,6}'
]);

Route::get('/imageratio/{name?}/{width?}/{height?}', function (Request $request) {
    // dump($request->route());
    return ImageService::imageratio($request);
})->where([
    'name' => '/?storage/uploads/[\d]{4}-\d{2}-\d{2}/\w+.[a-zA-Z]{3,4}',
    'width' => '\d+',
    'height' => '\d+'
]);
// Route::view("/aaa/{path?}" , 'welcome')->where("path", ".*")->middleware('web');
// $router->view(config('mojito.admin_route_path') . "/{path?}" , 'dashboard')->where("path", ".*")->middleware('web');

Route::post('/upload', [\App\Http\Controllers\UploadController::class, 'editor']);
Route::post('/upload/upload', [\App\Http\Controllers\UploadController::class, 'upload']);
Route::post('/upload/deletefile', [\App\Http\Controllers\UploadController::class, 'deletefile']);
Route::get('/upload/getlist', [\App\Http\Controllers\UploadController::class, 'getlist']);

Route::get('/test', [\App\Http\Controllers\TestController::class, 'index']);
Route::get('/test/t', [\App\Http\Controllers\TestController::class, 't']);

Route::get('/amap', [\App\Http\Controllers\TestController::class, 'amap']);
Route::get('/juhe', function () {
    return view('juhe');
});

Route::get('/{path?}', function () {
    return view('welcome');
});
